package com.mmall.util;

import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author:lzq
 * @date: 2018/3/20 12:19
 */
public class DateTimeUtil {

    public static final String formate_partten="yyyy-MM-dd HH:mm:ss";
    //str > date   joda time
    public static Date strToDate(String dateTimeStr){
        DateTimeFormatter timeFormatter = DateTimeFormat.forPattern(formate_partten);
        DateTime dateTime = timeFormatter.parseDateTime(dateTimeStr);
        return dateTime.toDate();
    }

    //date > str
    public static String dateToStr(Date date){
        if(date==null){
            return "";
        }
        return new DateTime(date).toString(formate_partten);
    }
}
